package com.myway.service.ibe.command;

import com.travelsky.ebuild.clientapi.axi.CalcCurrency;
import com.travelsky.ebuild.clientapi.axi.CalcCurrencyRequest;
import com.travelsky.ebuild.clientapi.axi.CalcCurrencyResult;
import com.travelsky.ebuild.clientapi.axi.POSType;

import java.util.Date;

/**
 * Created by yufei on 2018/6/26.
 */
public class RateChangeCommand extends BaseIBECommand{
    public void execute(String from , String to, double price){
        CalcCurrency calcCurrency = new CalcCurrency();

        CalcCurrencyRequest request = new CalcCurrencyRequest();

        POSType posType = this.configIBEClientPrice(calcCurrency);
        request.setPos(posType);
        request.setFromCurrency(from );
        request.setExchangeRateType(CalcCurrencyRequest.INT_IATA_CLEARING_HOUSE);
        request.setToCurrency(to);
        request.setAmount(price);
        request.setRateDate(new Date());
        try {
            CalcCurrencyResult result = calcCurrency.doConvert(request);
            result.getFareAmount();
            System.out.println(request);
        }catch (Exception e){
            e.printStackTrace();
        }
    }



}
